﻿using UnityEngine;
using System.Collections;
using System;

public class RangeMutationController : MonoBehaviour
{
    public float Min = -2;
    public float Max = 4;
    public UILabel LabelMin;
    public UILabel LabelMax;

    internal RangeAttribute range;

    private UISlider slider;
	
	void Start () {
        range = new RangeAttribute(Min, Max);
        slider = GetComponent<UISlider>();
	}
	
	void Update () {
	
	}

    public void OnChange()
    {
        float value = slider.value - 0.5f;             //normalize value
        float step = 1f / (slider.numberOfSteps - 1);  //eg: 0.25 - 0.5 - 0.75 - 1
        float stepSel = value / step;
        range = new RangeAttribute(Min + stepSel, Max + stepSel);
        LabelMin.text = range.min.ToString("+0;-0");
        LabelMax.text = range.max.ToString("+0;-0");
    }

    public float GetMin()
    {
        return range.min;
    }

    public float GetMax()
    {
        return range.max;
    }
}
